package swing;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JFrameAccionSeccion extends javax.swing.JFrame {
	private JPanel panAccionSeccion;
	private JLabel lblLogo;
	private JFormattedTextField jFormattedTextFieldSeccion;
	private JButton jbtnsalir;
	private JButton jbtnaccion;
	private JLabel jlblopcion;
	private JLabel jlblpromedionotas;
	private JTextField txtPromediodeNotas;
	JFrameCrearSeccion jfseccion = new JFrameCrearSeccion();
	private JComboBox cmbAccionSeccion;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrameAccionSeccion inst = new JFrameAccionSeccion();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public JFrameAccionSeccion() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Acciones Sobre la Sección");
			{
				panAccionSeccion = new JPanel();
				getContentPane().add(panAccionSeccion, BorderLayout.CENTER);
				GroupLayout panAccionSeccionLayout = new GroupLayout((JComponent)panAccionSeccion);
				panAccionSeccion.setLayout(panAccionSeccionLayout);
				panAccionSeccion.setBackground(new java.awt.Color(255,255,255));
				panAccionSeccion.setPreferredSize(new java.awt.Dimension(361, 338));
				{
					ComboBoxModel cmbAccionSeccionModel = 
						new DefaultComboBoxModel(
						new String[] { "Aplicar Evaluaciones", "Promedio de Notas" });
					cmbAccionSeccion = new JComboBox();
					cmbAccionSeccion.setModel(cmbAccionSeccionModel);
					cmbAccionSeccion.setEditable(false);

				{
					lblLogo = new JLabel();
					lblLogo.setIcon(new ImageIcon(getClass().getResource("escudo.jpeg")));
				}
				{
					jFormattedTextFieldSeccion = new JFormattedTextField();
					jFormattedTextFieldSeccion.setText("Inicio del Proceso de Evaluación");
					jFormattedTextFieldSeccion.setEditable(false);
					jFormattedTextFieldSeccion.setBackground(new java.awt.Color(24,87,227));
					jFormattedTextFieldSeccion.setForeground(new java.awt.Color(255,255,255));
					jFormattedTextFieldSeccion.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				}
				{
					jbtnsalir = new JButton();
					jbtnsalir.setIcon(new ImageIcon(getClass().getResource("salir.jpeg")));
					jbtnsalir.setBackground(new java.awt.Color(255,255,255));
					//jbtnsalir.setText("Salir");
					jbtnsalir.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							System.out.println("jbtnsalir.mouseClicked, event="+evt);
							
							//TODO add your code for btnEstudiante.mouseClicked
							JFrameMenu jfest = new JFrameMenu();
		    				 jfest.setLocationRelativeTo(null);
		    				 jfest.setVisible(true);
		    				 setVisible(false);
						}
					});
				}

				{
					jbtnaccion = new JButton();
					jbtnaccion.setText("Aplicar Acción");
					jbtnaccion.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							System.out.println("jbtnaccion.mouseClicked, event="+evt);
							//TODO add your code for jbtnaccion.mouseClicked
							if (cmbAccionSeccion.getSelectedItem().toString().equals("Aplicar Evaluaciones")){
								JFrameCrearSeccion.secc.aplicarEvaluaciones();
							}
							else if (cmbAccionSeccion.getSelectedItem().toString().equals("Promedio de Notas"))
							     if(JFrameCrearSeccion.secc.getAlumnos().size()>0 ){
								    JFrameCrearSeccion.secc.promedioNotas();
									txtPromediodeNotas.setText(String.valueOf(JFrameCrearSeccion.secc.promedioNotas()));		
								 }
								 else{
									JOptionPane.showMessageDialog(null,"Operacion Invalida, no hay estudiantes inscritos", "Aplicar Evaluaciones",JOptionPane.INFORMATION_MESSAGE);
							}
							else{
							jbtnaccion.setEnabled(false);
							}
						           
						}
					});
				}
				{
					txtPromediodeNotas = new JTextField();
					txtPromediodeNotas.setEditable(false);
				}
				{
					jlblpromedionotas = new JLabel();
					jlblpromedionotas.setText("Promedio de Notas de la Sección:");
				}
				{
					jlblopcion = new JLabel();
					jlblopcion.setText("Escoja una acción a aplicar");
				}
			}			
				panAccionSeccionLayout.setHorizontalGroup(panAccionSeccionLayout.createSequentialGroup()
				.addContainerGap()
				.addComponent(lblLogo, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
				.addGroup(panAccionSeccionLayout.createParallelGroup()
				    .addGroup(panAccionSeccionLayout.createSequentialGroup()
				        .addComponent(jFormattedTextFieldSeccion, GroupLayout.PREFERRED_SIZE, 264, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 0, Short.MAX_VALUE))
				    .addGroup(panAccionSeccionLayout.createSequentialGroup()
				        .addPreferredGap(jFormattedTextFieldSeccion, jlblpromedionotas, LayoutStyle.ComponentPlacement.INDENT)
				        .addGroup(panAccionSeccionLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				                .addComponent(jlblpromedionotas, GroupLayout.PREFERRED_SIZE, 238, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 14, Short.MAX_VALUE))
				            .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				                .addComponent(txtPromediodeNotas, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 180, Short.MAX_VALUE))
				            .addGroup(panAccionSeccionLayout.createSequentialGroup()
				                .addPreferredGap(jlblpromedionotas, jlblopcion, LayoutStyle.ComponentPlacement.INDENT)
				                .addGroup(panAccionSeccionLayout.createParallelGroup()
				                    .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				                        .addComponent(jlblopcion, GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE)
				                        .addGap(0, 42, Short.MAX_VALUE))
				                    .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				                        .addGap(17)
				                        .addGroup(panAccionSeccionLayout.createParallelGroup()
				                            .addComponent(cmbAccionSeccion, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                            .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				                                .addPreferredGap(cmbAccionSeccion, jbtnaccion, LayoutStyle.ComponentPlacement.INDENT)
				                                .addComponent(jbtnaccion, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE)
				                                .addGap(30)))
				                        .addGap(25)
				                        .addComponent(jbtnsalir, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
				                        .addGap(0, 0, Short.MAX_VALUE)))))))
				.addContainerGap(31, 31));
				panAccionSeccionLayout.setVerticalGroup(panAccionSeccionLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(panAccionSeccionLayout.createParallelGroup()
				    .addComponent(lblLogo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)
				    .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				        .addGap(36)
				        .addComponent(jFormattedTextFieldSeccion, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addGap(30)))
				.addComponent(jlblopcion, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(cmbAccionSeccion, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addGap(45)
				.addComponent(jbtnaccion, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addGap(19)
				.addComponent(jlblpromedionotas, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addGroup(panAccionSeccionLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				        .addComponent(txtPromediodeNotas, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 36, Short.MAX_VALUE))
				    .addGroup(GroupLayout.Alignment.LEADING, panAccionSeccionLayout.createSequentialGroup()
				        .addGap(0, 16, Short.MAX_VALUE)
				        .addComponent(jbtnsalir, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)))
				.addContainerGap(16, 16));
			}
			pack();
			this.setSize(351, 362);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
